#include "armKeyTest.h"

static constexpr rt_base_t pinArmKey = GET_PIN(B, 9); // get pin of arm-key

void ArmKey::run(void *parameter)
{
    this->keyInit();
    while (1)
    {
        rt_thread_mdelay(100);
    }
}

void ArmKey::buttonCallback(void *ptr)
{
    ArmKey *armKeyPtr = static_cast<ArmKey *>(ptr);
    armKeyPtr->ledSem->release();
}

void ArmKey::keyInit()
{
    rt_pin_mode(pinArmKey, PIN_MODE_INPUT_PULLDOWN);
    rt_pin_attach_irq(pinArmKey, PIN_IRQ_MODE_FALLING, ArmKey::buttonCallback, this);
    rt_pin_irq_enable(pinArmKey, PIN_IRQ_ENABLE);
}
